/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
    Text, BlobInputList,
} from "customize-easy-ui-component";
import {
    InspectRecordLayout, InternalItemProps, useItemInputControl,
} from "../../common/base";
import {useMeasureInpFilter} from "../../common/hooks";
import {Each_ZdSetting, useTableEditor} from "../../hook/useRepTableEditor";

interface Props  extends InternalItemProps{
    label?: string;
    config?: any[];    //有配置模式的 : 表对象的默认取值；
}

const cb问题概输入= (inp: any, setInp: React.Dispatch<React.SetStateAction<any>>,name:string) => {
    return  <BlobInputList value={(inp?.[name]) || ''} rows={5} datalist={[]}
                           onListChange={v => setInp({ ...inp, [name] :v || undefined}) } />
}
const cb处理情输入= (inp: any, setInp: React.Dispatch<React.SetStateAction<any>>,name:string) => {
    return  <BlobInputList value={(inp?.[name]) || ''} rows={3}
                           onListChange={v => setInp({ ...inp, [name] :v || undefined}) } />
}
const config问题处=[
    ['联络单/意见书编号','n',150],['问题概述','c',520,cb问题概输入],['处理情况','r',330,cb处理情输入]
] as Each_ZdSetting[];
export const itemA问题处=['问处表','问处结果'];
export const ProblemHandle=
    React.forwardRef(({ children, show ,alone=true,refWidth,label,}:Props,  ref
    ) => {
        const [getInpFilter]=useMeasureInpFilter(null,itemA问题处,);
        const {inp, setInp} = useItemInputControl({ ref });
        const headview=<Text variant="h5">
            {label}：
        </Text>;
        const [render]=useTableEditor({inp,setInp,
            headview, config: config问题处, table:'问处表',column:2 });
        return (
            <InspectRecordLayout inp={inp} setInp={setInp}  getInpFilter={getInpFilter} show={show}
                                 alone={alone}  label={label!}>
                {render}
                <Text variant="h4">监检结果：</Text>
                <BlobInputList  value={inp?.问处结果 ||''} rows={8} datalist={['符合要求。', ]}
                                onListChange={v => setInp({ ...inp, 问处结果: v || undefined}) } />
                { children }
            </InspectRecordLayout>
        );
    } );

